{include file="public/header"}
<style>
	.ecx_section2 .f1 .s1{
		font-size: 0.9rem;
		width: 120px;
	}
	.djk{
		background: url("__PUBLIC__/home/images/v10_a19.png");
		background-size: 100% 100%;
		padding: 10px;
	}
</style>
<body class="">
<div class="bg_fixed_v10_1"></div>
	<div class="sectionY sectionY_tttt">
		<a href="javascript:history.back();">
			<img src="__PUBLIC__/home/images/v10_a9.png" alt="" class="a1">
		</a>
		<p class="p1">
			<span class="ppp_title">兑换</span>
		</p>
	</div>
	<div class="kong1"></div>
	<div class="ecx_section1">
		<div class="container">
			<p class="p2">提醒：</p>
			<p class="p1">1个团队奖兑换{:config('setting.atc_rate')}个资产。最少兑换{:config('setting.atc_start')}个团队奖；最大兑换{:config('setting.atc_end')}个团队奖；</p>
			<p class="p1"></p>
		</div>
	</div>
	<div class="ecx_section2">
		<form action="">
			<div class="t1">
				<div class="djk">
					<div class="f1 clearfix">
						<span class="s1">剩余团队奖数量：</span>
						<input type="text" disabled value="{$userinfo.wagesall}">
					</div>
					<div class="f1 clearfix">
						<span class="s1">兑换资产：</span>
						<input type="text" name="salary" placeholder="请输入团队奖的数量">
					</div>
					<div class="f1 clearfix" style="border-bottom: none">
						<span class="s1">交易密码：</span>
						<input type="password" name="pwd" placeholder="请输入交易密码">
					</div>
				</div>
				<div class="sub">
					<input type="button" id="submit" value="确认兑换">
					<a href="javascript:history.back();" class="a1" style="border: 1px solid #29f5ff;background: none;color: #fff">取消</a>
				</div>
			</div>
		</form>
	</div>
</body>
<script>
	$(function(){
		$('#submit').click(function(){
			var num = $('input[name=salary]').val();
			var pwd = $('input[name=pwd]').val();
			if(num==''){
				layer.alert('请检查您要兑换的资产数量，资产兑换不能为空！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
			}
			if(pwd==''){
				layer.alert('请输入交易密码！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
			}
			$.ajax({
				type: 'POST',
				url: "{:url('User/atcChange')}",
				dataType: "html",
				data: "num="+num+"&pwd="+pwd,
				success:function(responsestr){
					var str = isJSON(responsestr);
					if(str==1){
						var obj=JSON.parse(responsestr);
						if(obj.s==10){
							layer.msg('成功！',{shade:0.6,time:1000,end:function(){
									window.location.href=window.location.href;
									return false;
								}});
						}else{
							layer.alert(obj.msg,{shade:0.2});return false;
						}
					}else{
						layer.alert('系统正忙，请稍后再试！',{shade:0.2});
					}
				},
				error:function(){
					layer.alert('系统繁忙，请稍后再试！',{shade:0.2});
				}
			});
		});
	})

	function isJSON(str) {
		if (typeof str == 'string') {
			try{
				var obj=JSON.parse(str);
				if(str.indexOf('{')>-1){
					return 1;
				}else{
					return 0;
				}
			}catch(e){
				return 0;
			}
		}
		return 0;
	}
</script>
</html>
